<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
//首页广告、新品、热销遍历页面
    public function index(){
    	$model=M('category');
		$sql="select `name`,`id` from `category` where status=1 and pid=0";
		$list=$model->query($sql);
		foreach ($list as $k => $v) 
		{
			$sql1="select `name`,`id` from `category` where pid=".$v['id']." and status=1";
			$res=$model->query($sql1);
			$list[$k]['son']=$res;
		}
		//var_dump($list);exit;
		//遍历新品及热销
		$goods_model=D('goods');
		$new=[];
		$hot=[];
		$num=1;
		$goods_list=$goods_model->getAll();
		//var_dump($goods_list);exit;

		if (!empty($goods_list)) 
		{
			foreach ($goods_list as $k => $v) 
			{
				/*if ($num>8) 
				{
					break;
				}*/
				if ($v['gnew']==1) 
				{
					$new[]=$v;
				}
				if ($v['ghot']==1) 
				{
					$hot[]=$v;
				}
				$num++;
			}
		}
		if (!empty($new)) 
		{
			foreach ($new as $key => $value) 
			{
				$new[$key]['giname']='/Public/Uploads/'.$this->sub($value['giname']).'322_'.$value['giname'];
			}
		}
		if (!empty($hot)) 
		{
			foreach ($hot as $ke => $val) 
			{
				$hot[$ke]['giname']='/Public/Uploads/'.$this->sub($val['giname']).'322_'.$val['giname'];
			}
		}
		//var_dump($new);
		//var_dump($hot);exit;

		//广告遍历
		$ad_sql="select `name`,`location` from `advertisement` where status=1";
		$ad_model=M('advertisement');
		$ad_list=$ad_model->query($ad_sql);
		$adarray=array();
		foreach ($ad_list as $key => $value) 
		{
			if ($value['location']==1) 
			{
			$adarray['name']='/Public/Uploads/'.$this->sub($value['name']).$value['name'];
			}
		}
		$this->assign('adarray',$adarray);
		$this->assign('list',$list);
		$this->assign('new',$new);
		$this->assign('hot',$hot);
        $this->display();
    }
//遍历所有商品页面
    public function product()
    {
    	$model=M('category');
		$sql="select `name`,`id` from `category` where status=1 and pid=0";
		$list=$model->query($sql);
		foreach ($list as $k => $v) 
		{
			$sql1="select `name`,`id` from `category` where pid=".$v['id']." and status=1";
			$res=$model->query($sql1);
			$list[$k]['son']=$res;
		}

		$goods_model=D('goods');
		$goods_list=$goods_model->getAll();
		foreach ($goods_list as $ke => $val) 
		{
			$goods_list[$ke]['giname']='/Public/Uploads/'.$this->sub($val['giname']).'322_'.$val['giname'];
		}
		//var_dump($goods_list);exit;
		$this->assign('list',$list);
		$this->assign('goods_list',$goods_list);
    	$this->display();
    }
//遍历商品详情页面
     public function single()
    {
    	$model=M('category');
		$sql="select `name`,`id` from `category` where status=1 and pid=0";
		$list=$model->query($sql);
		foreach ($list as $k => $v) 
		{
			$sql1="select `name`,`id` from `category` where pid=".$v['id']." and status=1";
			$res=$model->query($sql1);
			$list[$k]['son']=$res;
		}

		$goods_model=D('goods');
		$goods_list=$goods_model->getAll();
		foreach ($goods_list as $ke => $val) 
		{
			$goods_list[$ke]['giname']='/Public/Uploads/'.$this->sub($val['giname']).$val['giname'];
		}
		//var_dump($goods_list);exit;
		//遍历商品
		//接受商品的id
		$id=$_GET['id'];	
		$good_list1=$goods_model->getSingle($id);
		foreach ($good_list1 as $ke => $val) 
		{
			$good_list1[$ke]['giname']='/Public/Uploads/'.$this->sub($val['giname']).$val['giname'];
			$good_list1[$ke]['gtime']=date('Y年m月d日',$val['gtime']);
		}
		$good_list=$good_list1[0];
		//var_dump($good_list);exit;
		$img_model=M('goods_img');
		//查看图片
		$img_sql="select `name` from `goods_img` where goods_id=$id and is_cover=0 limit 0,3";
		$goods_img=$img_model->query($img_sql);
		//var_dump($goods_img);exit;
		if (!empty($goods_img)) 
		{
			foreach ($goods_img as $key => $value) 
			{
				$goods_img[$key]['name']='/Public/Uploads/'.$this->sub($value['name']).'125_'.$value['name'];
		}
	}
	//var_dump($goods_img);exit;
		$this->assign('good_list',$good_list);
		$this->assign('goods_img',$goods_img);
		$this->assign('list',$list);
		$this->assign('goods_list',$goods_list);
    	$this->display();
    }
//遍历购物车页面
    public function cart()
    	{
    		//遍历分类
	    	$model=M('category');
			$sql="select `name`,`id` from `category` where status=1 and pid=0";
			$list=$model->query($sql);
			foreach ($list as $k => $v) 
			{
				$sql1="select `name`,`id` from `category` where pid=".$v['id']." and status=1";
				$res=$model->query($sql1);
				$list[$k]['son']=$res;
			}
			$this->assign('list',$list);
    		$this->display();

			//加入购物车,订单遍历
			$id=$_POST['id'];
			//echo $id;exit;
			$num=$_POST['num'];
			if ($num<1) $num=1;
//echo $id;exit;
			//判断是否重复购买
			if (!empty($_SESSION['car'][$id])) 
			{
				$_SESSION['car'][$id]['num']+=$num;
				//var_dump($_SESSION['car']);
				$this->redirect('Index/cart');
				//$this->display('Index/cart');
				return false;
			}
//echo $id;exit;
			//查询商品信息
			$goods_model=D('goods');
			//echo $id;exit;
			$list1=$goods_model->getSingle($id);
			foreach ($list1 as $k => $v) 
			{
			$list1[$k]['giname']='/Public/Uploads/'.$this->sub($v['giname']).'150_'.$v['giname'];
			}
			$goods_list=$list1[0];
			$goods_list['num']=$num;

			//把商品信息放进session
			$_SESSION['car'][$id]=$goods_list;
			//var_dump($_SESSION['car'][$id]);exit;
			$this->redirect('Index/cart');
			
		}
//购物车商品删除功能，只是在session中
	public function cartdel()
	{
		$id=$_GET['id'];
		unset($_SESSION['car'][$id]);
		$this->redirect('Index/cart');
		//$this->display('Index/cart');
	}
//购物车清空功能
	public function cartreset()
	{
		unset($_SESSION['car']);
		$this->redirect('Index/cart');
		//$this->display('Index/cart');
	}
//遍历订单页面(地址及订单详情)
	public function order()
	{
		//判断是否登录
		if (empty($_SESSION['home'])) 
		{
			$this->success('你还没有登录',U('Index/login'),1);
			return false;
		}
		//遍历分类
	    $model=M('category');
		$sql="select `name`,`id` from `category` where status=1 and pid=0";
		$list=$model->query($sql);
		foreach ($list as $k => $v) 
		{
			$sql1="select `name`,`id` from `category` where pid=".$v['id']." and status=1";
			$res=$model->query($sql1);
			$list[$k]['son']=$res;
		}
		//遍历地址表
		$add_model=M('address');
		$addlist=$add_model->select();
		//var_dump($addlist);exit;
		$this->assign('list',$list);
		$this->assign('addlist',$addlist);
	    $this->display();
	}
//地址信息填写页面及添加功能
	public function address()
	{
		//判断是否登录
		if (empty($_SESSION['home'])) 
		{
			$this->success('你还没有登录',U('Index/login'),1);
			return false;
		}

		if (empty($_POST)) 
		{	//遍历分类
			$model=M('category');
			$sql="select `name`,`id` from `category` where status=1 and pid=0";
			$list=$model->query($sql);
			foreach ($list as $k => $v) 
			{
				$sql1="select `name`,`id` from `category` where pid=".$v['id']." and status=1";
				$res=$model->query($sql1);
				$list[$k]['son']=$res;
			}
			$this->assign('list',$list);
			$this->display();
			return false;
		}
		$addressModel=D('address');
		//验证表单提交是否为空
		$data=$addressModel->create();
		//var_dump($data);exit;
		if (!$data) {
			$this->error($addressModel->getError());
		}else{
			$data['uid']=$_SESSION['home']['id'];
	    	$res=$addressModel->getAdd($data);
			if ($res) 
			{
				$this->success('添加地址成功',U('Index/order'),2);
			}else{
				$this->error('添加地址失败');
			}
	    }
	}
//最终确认功能(提交地址选择及订单跳转到流程最后页面)
	public function confirm()
	{
		//var_dump($_POST['add_id']);exit;
		//判断是否选择地址
		if (empty($_POST['add_id'])) 
		{
			$this->error('请选择收货地址！');
			return false;
		}
		$list_model=D('order_list');
		//验证地址是否为空
		$data=$list_model->create();
		//echo $data;exit;
		if (!$data) {
			$this->error($list_model->getError());
		}else{
			$data['ordernumber']='mz'.date('Ymd',time()).uniqid().rand(0,9999);
			$data['uid']=$_SESSION['home']['id'];
			//插入数据库
			$order_id=$list_model->getAdd($data);

			//循环将商品插入到订单详情表
			foreach ($_SESSION['car'] as $k => $v) 
			{//var_dump($_SESSION['car']);exit;
				$dat['goods_id']=$v['gid'];
				$dat['order_id']=$order_id;
				$dat['num']=$v['num'];
				$info_model=M('order_info');
				$result=$info_model->add($dat);
			}
			//var_dump($_SESSION['car']);exit;
			if ($result) 
			{
				unset($_SESSION['car']);
				//遍历分类
				$model=M('category');
				$sql="select `name`,`id` from `category` where status=1 and pid=0";
				$list=$model->query($sql);
				foreach ($list as $k => $v) 
				{
					$sql1="select `name`,`id` from `category` where pid=".$v['id']." and status=1";
					$res=$model->query($sql1);
					$list[$k]['son']=$res;
				}
					$this->assign('list',$list);
					$this->display();				
			}
	    }
	}	
//进入个人中心总页面
	public function person()
	{
		//遍历分类
		$model=M('category');
		$sql="select `name`,`id` from `category` where status=1 and pid=0";
		$list=$model->query($sql);
		foreach ($list as $k => $v) 
		{
			$sql1="select `name`,`id` from `category` where pid=".$v['id']." and status=1";
			$res=$model->query($sql1);
			$list[$k]['son']=$res;
		}
			$this->assign('list',$list);
			$this->display();	
	}
//个人中心订单详情
	public function personorder()
	{
		//遍历分类
		$model=M('category');
		$sql="select `name`,`id` from `category` where status=1 and pid=0";
		$list=$model->query($sql);
		foreach ($list as $k => $v) 
		{
			$sql1="select `name`,`id` from `category` where pid=".$v['id']." and status=1";
			$res=$model->query($sql1);
			$list[$k]['son']=$res;
		}

		$uid=$_SESSION['home']['id'];
		$where['uid']=$uid;
		//查询数据
		$order_model=D('order_list');

		//总条数
		$total=$order_model->where($where)->count();
		//echo $total;exit;
		//总页数
		$page=new \Think\Page($total,2);
		$page->setConfig('header','总页数');
		$page->setConfig('prev','上一页');
		$page->setConfig('next','下一页');
		//获取当前页
		$p=$page->nowPage;

		$page_str=$page->show();
		//echo $page_str;exit;
		$limit=$page->firstRow.','.$page->listRows;

		$order_list=$order_model->getAll($uid,$limit);
		//var_dump($order_list);exit;
		foreach ($order_list as $key => $value) 
		{
			$order_list[$key]['ordertime']=date('Y年m月d日',$value['ordertime']);
			foreach ($value['son'] as $k => $v) 
			{
				$value['son'][$k]['giname']='/Public/Uploads/'.$this->sub($v['giname']).'80_'.$v['giname'];
			}
			//var_dump($value['son']);exit;
			$order_list[$key]['son']=$value['son'];
		}
		//var_dump($order_list);exit;
		//发送数据
		$this->assign('page',$page_str);
		$this->assign('p',$p);
		$this->assign('list',$list);
		$this->assign('order_list',$order_list);
		//加载模板
		$this->display();	
	}
//买家确认收货功能
	public function getgoods()
	{
		$p=$_GET['p'];
		$id=$_GET['id'];
		$data['is_delivery']=2;
		$where['id']=$id;
		$model=M('order_list');
		$res=$model->where($where)->save($data);
		if ($res) 
		{
			$this->redirect('Index/personorder',['p'=>$p]);
		}
	}
//买家付款功能
	public function pay()
	{
		$p=$_GET['p'];
		$id=$_GET['id'];
		$sql="select `is_pay` from `order_list` where id=$id";
		$model=M('order_list');
		$is_pay=$model->query($sql)[0]['is_pay'];
		$is_pay=$is_pay?0:1;

		$data['is_pay']=$is_pay;
		$where['id']=$id;

		$res=$model->where($where)->save($data);
		if ($res) 
		{
			$this->success('付款成功',U('Index/personorder',['p'=>$p]),1);
			return false;
		}
	}
//个人订单详情及评论查看
	public function detailord()
	{
		//遍历分类
		$model=M('category');
		$sql="select `name`,`id` from `category` where status=1 and pid=0";
		$list=$model->query($sql);
		foreach ($list as $k => $v) 
		{
			$sql1="select `name`,`id` from `category` where pid=".$v['id']." and status=1";
			$res=$model->query($sql1);
			$list[$k]['son']=$res;
		}

		$id=$_GET['id'];
		//查询数据
		$order_model=D('order_info');

		//总条数
		$total=$order_model->getCount($id);
		//echo $total;exit;
		//总页数
		$page=new \Think\Page($total,1);
		$page->setConfig('header','总页数');
		$page->setConfig('prev','上一页');
		$page->setConfig('next','下一页');
		//获取当前页
		$p=$page->nowPage;

		$page_str=$page->show();
		//echo $page_str;exit;
		$limit=$page->firstRow.','.$page->listRows;

		$goods_list=$order_model->getAll($id,$limit);
		foreach ($goods_list as $ke => $val) 
		{
			$goods_list[$ke]['giname']='/Public/Uploads/'.$this->sub($val['giname']).'80_'.$val['giname'];
			$goods_list[$ke]['gtime']=date('Y年m月d日',$val['gtime']);
		}
		//var_dump($goods_list);exit;
		//查询评论语句
		$sql="select c.id id,c.text text,c.comtime comtime,c.status status,c.reply reply,u.username uname from `comments` c,`user` u where c.uid=u.id and c.status=1 and c.order_id=$id";
		$com_model=M('comments');
		$com_list=$com_model->query($sql);
		foreach ($com_list as $ke => $val) 
		{
			$com_list[$ke]['comtime']=date('Y年m月d日',$val['comtime']);
		}
		//var_dump($com_list);exit;
		//发送数据
		$this->assign('page',$page_str);
		$this->assign('p',$p);
		//echo $id;exit;
		$this->assign('id',$id);
		$this->assign('list',$list);
		$this->assign('goods_list',$goods_list);
		$this->assign('com_list',$com_list);
		//加载模板
		$this->display();	
	}

//评论功能
	public function comment()
	{
		$id=$_POST['id'];
		$order_model=M('order_list');
		$sql="select `is_delivery` from `order_list` where id=$id";
		$result=$order_model->query($sql)[0]['is_delivery'];
		if ($result!=2) 
		{
			$this->error('还木有签收，等一下下再给好评吧！');
			return false;
		}else{
			$data['order_id']=$_POST['id'];
			$data['uid']=$_SESSION['home']['id'];
			$data['text']=$_POST['text']?$_POST['text']:'系统默认好评！';
			$data['comtime']=time();
			//var_dump($data);exit;
			$com_model=M('comments');

			$res=$com_model->add($data);
			if ($res) 
			{
				$this->success('评论发表成功，等待审核！',U('Index/detailord',['id'=>$id]),1);
				return false;
			}
		}
	}
//个人信息修改密码功能
	public function personmodify()
	{
		if (empty($_POST)) {
    		$model=M('category');
			$sql="select `name`,`id` from `category` where status=1 and pid=0";
			$list=$model->query($sql);
			foreach ($list as $k => $v) 
			{
				$sql1="select `name`,`id` from `category` where pid=".$v['id']." and status=1";
				$res=$model->query($sql1);
				$list[$k]['son']=$res;
			}
			$uid=$_SESSION['home']['id'];
			//var_dump($_SESSION['home']['id']);exit;
			$this->assign('list',$list);
			$this->assign('uid',$uid);
			$this->display();
			return false;
    	}  
	}

//密码修改功能
	public function pwdreset()
	{
		$id=$_GET['id'];

		if (!empty($_POST)) 
		{
			foreach ($_POST as $key => $value) 
			{
				if (empty($value)) 
				{
					$this->error('密码不能为空!');
					return false;
				}
			}
		}
		$pwd1=md5($_POST['pwd1']);
		$pwd2=md5($_POST['pwd2']);
		
		//查询原始密码
		$where['id']=$id;
		$model=M('user');
		$res=$model->where($where)->getField('pwd');
		//var_dump($res);
		if ($pwd1==$res) 
		{
			$data['pwd']=$pwd2;
			$result=$model->where($where)->save($data);
			if ($result) 
			{
				$this->success('修改密码成功！',U('Index/personmodify'),1);
				return false;
			}
		}else
		{
			$this->error('初始密码错误！');
			return false;
		}
	}
//个人信息遍历页面
	public function personinfo()
	{
		$model=M('category');
		$sql="select `name`,`id` from `category` where status=1 and pid=0";
		$list=$model->query($sql);
		foreach ($list as $k => $v) 
		{
			$sql1="select `name`,`id` from `category` where pid=".$v['id']." and status=1";
			$res=$model->query($sql1);
			$list[$k]['son']=$res;
		}

		//遍历个人信息
		$uid=$_SESSION['home']['id'];
		$model=M('user_info');
		$where['uid']=$uid;
		$res1=$model->where($where)->select();
		foreach ($res1 as $k => $v) 
		{
			$res1[$k]['face']=$v['face']?'/Public/Uploads/'.$this->sub($v['face']).$v['face']:'/Public/Images/no.jpg';
			$res1[$k]['name']=$v['name']?$v['name']:'没有昵称';
			$res1[$k]['age']=$v['age']?$v['age']:'还没有出生';
			$res1[$k]['logintime']=date('Y年m月d日 H:i:s',$_SESSION['home']['logintime']);
		}
		//$res=$res1[0];
		//var_dump($_SESSION['home']);exit;
		//var_dump($res);exit;
		$this->assign('list',$list);
		$this->assign('res1',$res1);
		$this->display();
	}

//完善个人信息
	public function infocomplete()
	{
		/*var_dump($_FILES);exit;*/
		if (empty($_POST)) 
		{
			$model=M('category');
			$sql="select `name`,`id` from `category` where status=1 and pid=0";
			$list=$model->query($sql);
			foreach ($list as $k => $v) 
			{
				$sql1="select `name`,`id` from `category` where pid=".$v['id']." and status=1";
				$res=$model->query($sql1);
				$list[$k]['son']=$res;
			}
			$this->assign('list',$list);
			$this->display();
			return false;
		}

		$info_model=D('user_info');
		//根据表单提交的POST数据创建数据对象
		//$_POST['face']=$_FILES['face']['name'];
		$_POST['sex']=$_POST['sex']==2?0:1;
		$data=$info_model->create();
		//var_dump($data);exit;
		if (!$data) 
		{
		// 如果创建失败表示验证没有通过 输出错误提示信息
			$this->error($info_model->getError());
		}else{
			$filename=$this->upload();
			//var_dump($filename);eixt;
			$data['face']=$filename;
			$data['uid']=$_SESSION['home']['id'];
			//var_dump($data);exit;
			$res=$info_model->setAdd($data);
			if ($res) 
			{//添加成功
				$this->success('个人信息完善成功',U('Index/personinfo'),2);
			return false;
			}else{
				$this->setUnlink($filename);
				$this->error('添加失败');
			}
		}

	}
//登录页面及功能
    public function login(){
    	if (empty($_POST)) {
    		$model=M('category');
			$sql="select `name`,`id` from `category` where status=1 and pid=0";
			$list=$model->query($sql);
			foreach ($list as $k => $v) 
			{
				$sql1="select `name`,`id` from `category` where pid=".$v['id']." and status=1";
				$res=$model->query($sql1);
				$list[$k]['son']=$res;
			}
			$this->assign('list',$list);
			$this->display();
			return false;
    	}  
    	//实例化model类
    	$userModel=D('user');
    	//create方法是对表单提交的POST数据进行自动验证
    	$data=$userModel->create();   	
    	if (!$data) 
    	{
    		$this->error($userModel->getError());
    	}else{
    		//有用户名和密码再判断验证码
    		$res=$this->check($_POST['yzm']);
	    	if (!$res) 
	    	{
	    		$this->error('验证码错误');
	    	}else{
	    		//查询数据
	    		unset($data['regtime']);
	    		$data['status']=1;
	    		//var_dump($data);exit;
	    		$res=$userModel->getFind($data);
	    		if (is_null($res)) 
	    		{
	    			$this->error('用户名或密码错误');
	    		}else{
	    			//var_dump($res);exit;
	    			unset($res['pwd']);
	    			$_SESSION['home']=$res;
	    			$_SESSION['home']['logintime']=time();
	    			//var_dump($_SESSION);exit;
	    			$this->success('登录成功',U('index'),2);
    		}
    	}
    }
}
//退出登录
	public function loginOut(){
		unset($_SESSION['home']);
		$this->success('退出成功',U('index'),2);
	}
//注册页面及功能
	public function reg()
	{
		if (empty($_POST)) 
		{
			$model=M('category');
			$sql="select `name`,`id` from `category` where status=1 and pid=0";
			$list=$model->query($sql);
			foreach ($list as $k => $v) 
			{
				$sql1="select `name`,`id` from `category` where pid=".$v['id']." and status=1";
				$res=$model->query($sql1);
				$list[$k]['son']=$res;
			}
			$this->assign('list',$list);
			$this->display();
			return false;
		}
		$userModel=D('user');
		$data=$userModel->create();
		if (!$data) {
			$this->error($userModel->getError());
		}else{
			//有用户名和密码及确认密码再判断验证码
    		$res=$this->check($_POST['yzm']);
	    	if (!$res) 
	    	{
	    		$this->error('验证码错误');
	    	}else{
	    		$res=$userModel->getAdd($data);
				if ($res) 
				{
					$this->success('注册成功',U('login'),2);
				}else{
					$this->error('注册失败');
				}
	    	}
		}
		
	}

    public function yzm()
    {
    	$verify=new \Think\Verify();
    	$verify->fontSize=20;
    	$verify->length=4;
    	$verify->useNoise=false;
    	$verify->entry();
    }

    private function check($code,$id)
    {
    	$verify=new \Think\Verify();
    	return $verify->check($code,$id);
    }

    //文件上传
		public function upload(){
			//实例化上传类
			$upload=new \Think\Upload();
			//设置附件上传大小
			$upload->maxSize=3145728;
			//设置附件上传类型
			$upload->exts=array('jpg','gif','png','jpeg');
			//设置附件上传目录
			$upload->rootPath='./Public/';
			$upload->savePath='./Uploads/';
			$upload->saveName=date('Ymd',time()).uniqid();
			$upload->autoSub=true;
			$upload->subName=date('Y',time()).'/'.date('m',time()).'/'.date('d',time());
			

			//上传文件,返回成功上传的文件信息数组
			$info=$upload->upload();//
			//echo $upload->getError();
			
			if (!$info) 
			{
				//上传错误提示错误信息
				$this->error($upload->getError());
			}else{
				//上传成功
				//做图片压缩
				$this->zoom($info['myfile']['savename']);
				return $info['myfile']['savename'];
			}
		}

		private function sub($str)
		{
			return substr($str, 0,4).'/'.substr($str, 4,2).'/'.substr($str, 6,2).'/';
		}

		private function zoom($filename)
		{
			$image=new \Think\Image();
			$path='./Public/Uploads/'.$this->sub($filename);
			$image->open($path.$filename);
			//按照原图的比例生成一个缩略图并保存
			$image->thumb(233,322)->save($path.'322_'.$filename);
			$image->thumb(150,150)->save($path.'150_'.$filename);
			$image->thumb(300,300)->save($path.'300_'.$filename);
			$image->thumb(98,125)->save($path.'125_'.$filename);
			$image->thumb(80,80)->save($path.'80_'.$filename);
		}

		private function setUnlink($filename){
			$path='./Public/Uploads/';
			unlink($path.$this->sub($filename).$filename);
			unlink($path.$this->sub($filename).'150_'.$filename);
			unlink($path.$this->sub($filename).'322_'.$filename);
			unlink($path.$this->sub($filename).'300_'.$filename);
			unlink($path.$this->sub($filename).'125_'.$filename);
			unlink($path.$this->sub($filename).'80_'.$filename);
		}
}